<?php
session_start ();
// 使用php绘图技术，画出自己的验证码
$checkCode = "";
for($i = 0; $i < 4; $i ++) {
	$checkCode .= dechex ( rand ( 1, 15 ) );
}
// 存入到
$_SESSION ['checkcode'] = $checkCode;

// 创建画布
$image1 = imagecreatetruecolor ( 80, 22 );

$red = imagecolorallocate ( $image1, 255, 255, 255 );

// 画干扰线
for($i = 0; $i < 20; $i ++) {
	imageline ( $image1, rand ( 0, 110 ), rand ( 0, 30 ), rand ( 0, 110 ), rand ( 0, 30 ), imagecolorallocate ( $image1, rand ( 0, 255 ), rand ( 0, 255 ), rand ( 0, 255 ) ) );
}

imagestring ( $image1, rand ( 4, 8 ), rand ( 0, 50 ), rand ( 0, 10 ), $checkCode, $red );

header ( "content-type: image/png" );
imagepng ( $image1 );
imagedestroy ( $image1 );
?>